home *** CD-ROM | disk | FTP | other *** search
- head 5.9;
- branch 5.9.0;
- access;
- symbols
- RELEASE:5.9.0.14
- BETA:5.9.0.13
- UICSO:5.9.0
- VANILLA:5.9;
- locks; strict;
- comment @ * @;
-
-
- 5.9
- date 90.06.20.08.35.25; author paul; state Exp;
- branches
- 5.9.0.1;
- next ;
-
- 5.9.0.1
- date 90.06.20.09.42.35; author paul; state Exp;
- branches;
- next 5.9.0.2;
-
- 5.9.0.2
- date 90.11.28.16.27.30; author paul; state Exp;
- branches;
- next 5.9.0.3;
-
- 5.9.0.3
- date 91.02.01.04.49.26; author paul; state Exp;
- branches;
- next 5.9.0.4;
-
- 5.9.0.4
- date 91.02.17.03.49.25; author paul; state Exp;
- branches;
- next 5.9.0.5;
-
- 5.9.0.5
- date 91.03.04.21.48.23; author paul; state Exp;
- branches;
- next 5.9.0.6;
-
- 5.9.0.6
- date 91.03.05.16.46.48; author paul; state Exp;
- branches;
- next 5.9.0.7;
-
- 5.9.0.7
- date 91.03.05.23.04.43; author paul; state Exp;
- branches;
- next 5.9.0.8;
-
- 5.9.0.8
- date 91.04.05.06.33.33; author paul; state Exp;
- branches;
- next 5.9.0.9;
-
- 5.9.0.9
- date 91.04.05.14.55.15; author paul; state Exp;
- branches;
- next 5.9.0.10;
-
- 5.9.0.10
- date 91.04.30.16.44.59; author paul; state Exp;
- branches;
- next 5.9.0.11;
-
- 5.9.0.11
- date 91.05.20.22.31.10; author paul; state Exp;
- branches;
- next 5.9.0.12;
-
- 5.9.0.12
- date 91.05.21.17.27.50; author paul; state Exp;
- branches;
- next 5.9.0.13;
-
- 5.9.0.13
- date 91.05.29.19.36.13; author paul; state Exp;
- branches;
- next 5.9.0.14;
-
- 5.9.0.14
- date 91.06.21.12.37.55; author paul; state Exp;
- branches;
- next ;
-
-
- desc
- @@
-
-
- 5.9
- log
- @5.64 Berkeley release
- @
- text
- @/*
- * Copyright (c) 1983 Eric P. Allman
- * Copyright (c) 1988 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted provided
- * that: (1) source distributions retain this entire copyright notice and
- * comment, and (2) distributions including binaries display the following
- * acknowledgement: ``This product includes software developed by the
- * University of California, Berkeley and its contributors'' in the
- * documentation or other materials provided with the distribution and in
- * all advertising materials mentioning features or use of this software.
- * Neither the name of the University nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
- #ifndef lint
- static char sccsid[] = "@@(#)collect.c 5.9 (Berkeley) 6/1/90";
- #endif /* not lint */
-
- # include <errno.h>
- # include "sendmail.h"
-
- /*
- ** COLLECT -- read & parse message header & make temp file.
- **
- ** Creates a temporary file name and copies the standard
- ** input to that file. Leading UNIX-style "From" lines are
- ** stripped off (after important information is extracted).
- **
- ** Parameters:
- ** sayok -- if set, give an ARPANET style message
- ** to say we are ready to collect input.
- **
- ** Returns:
- ** none.
- **
- ** Side Effects:
- ** Temp file is created and filled.
- ** The from person may be set.
- */
-
- collect(sayok)
- bool sayok;
- {
- register FILE *tf;
- char buf[MAXFIELD], buf2[MAXFIELD];
- register char *workbuf, *freebuf;
- register int workbuflen;
- extern char *hvalue();
- extern bool isheader(), flusheol();
-
- /*
- ** Create the temp file name and create the file.
- */
-
- CurEnv->e_df = newstr(queuename(CurEnv, 'd'));
- if ((tf = dfopen(CurEnv->e_df, "w")) == NULL)
- {
- syserr("Cannot create %s", CurEnv->e_df);
- NoReturn = TRUE;
- finis();
- }
- (void) chmod(CurEnv->e_df, FileMode);
-
- /*
- ** Tell ARPANET to go ahead.
- */
-
- if (sayok)
- message("354", "Enter mail, end with \".\" on a line by itself");
-
- /*
- ** Try to read a UNIX-style From line
- */
-
- if (sfgets(buf, MAXFIELD, InChannel) == NULL)
- goto readerr;
- fixcrlf(buf, FALSE);
- # ifndef NOTUNIX
- if (!SaveFrom && strncmp(buf, "From ", 5) == 0)
- {
- if (!flusheol(buf, InChannel))
- goto readerr;
- eatfrom(buf);
- if (sfgets(buf, MAXFIELD, InChannel) == NULL)
- goto readerr;
- fixcrlf(buf, FALSE);
- }
- # endif NOTUNIX
-
- /*
- ** Copy InChannel to temp file & do message editing.
- ** To keep certain mailers from getting confused,
- ** and to keep the output clean, lines that look
- ** like UNIX "From" lines are deleted in the header.
- */
-
- workbuf = buf; /* `workbuf' contains a header field */
- freebuf = buf2; /* `freebuf' can be used for read-ahead */
- for (;;)
- {
- /* first, see if the header is over */
- if (!isheader(workbuf))
- {
- fixcrlf(workbuf, TRUE);
- break;
- }
-
- /* if the line is too long, throw the rest away */
- if (!flusheol(workbuf, InChannel))
- goto readerr;
-
- /* it's okay to toss '\n' now (flusheol() needed it) */
- fixcrlf(workbuf, TRUE);
-
- workbuflen = strlen(workbuf);
-
- /* get the rest of this field */
- for (;;)
- {
- if (sfgets(freebuf, MAXFIELD, InChannel) == NULL)
- goto readerr;
-
- /* is this a continuation line? */
- if (*freebuf != ' ' && *freebuf != '\t')
- break;
-
- if (!flusheol(freebuf, InChannel))
- goto readerr;
-
- /* yes; append line to `workbuf' if there's room */
- if (workbuflen < MAXFIELD-3)
- {
- register char *p = workbuf + workbuflen;
- register char *q = freebuf;
-
- /* we have room for more of this field */
- fixcrlf(freebuf, TRUE);
- *p++ = '\n'; workbuflen++;
- while(*q != '\0' && workbuflen < MAXFIELD-1)
- {
- *p++ = *q++;
- workbuflen++;
- }
- *p = '\0';
- }
- }
-
- CurEnv->e_msgsize += workbuflen;
-
- /*
- ** The working buffer now becomes the free buffer, since
- ** the free buffer contains a new header field.
- **
- ** This is premature, since we still havent called
- ** chompheader() to process the field we just created
- ** (so the call to chompheader() will use `freebuf').
- ** This convolution is necessary so that if we break out
- ** of the loop due to H_EOH, `workbuf' will always be
- ** the next unprocessed buffer.
- */
-
- {
- register char *tmp = workbuf;
- workbuf = freebuf;
- freebuf = tmp;
- }
-
- /*
- ** Snarf header away.
- */
-
- if (bitset(H_EOH, chompheader(freebuf, FALSE)))
- break;
- }
-
- if (tTd(30, 1))
- printf("EOH\n");
-
- if (*workbuf == '\0')
- {
- /* throw away a blank line */
- if (sfgets(buf, MAXFIELD, InChannel) == NULL)
- goto readerr;
- }
- else if (workbuf == buf2) /* guarantee `buf' contains data */
- (void) strcpy(buf, buf2);
-
- /*
- ** Collect the body of the message.
- */
-
- do
- {
- register char *bp = buf;
-
- fixcrlf(buf, TRUE);
-
- /* check for end-of-message */
- if (!IgnrDot && buf[0] == '.' && (buf[1] == '\n' || buf[1] == '\0'))
- break;
-
- /* check for transparent dot */
- if (OpMode == MD_SMTP && !IgnrDot && bp[0] == '.' && bp[1] == '.')
- bp++;
-
- /*
- ** Figure message length, output the line to the temp
- ** file, and insert a newline if missing.
- */
-
- CurEnv->e_msgsize += strlen(bp) + 1;
- fputs(bp, tf);
- fputs("\n", tf);
- if (ferror(tf))
- tferror(tf);
- } while (sfgets(buf, MAXFIELD, InChannel) != NULL);
-
- readerr:
- if (fflush(tf) != 0)
- tferror(tf);
- (void) fclose(tf);
-
- /* An EOF when running SMTP is an error */
- if ((feof(InChannel) || ferror(InChannel)) && OpMode == MD_SMTP)
- {
- int usrerr(), syserr();
- # ifdef LOG
- if (RealHostName != NULL && LogLevel > 0)
- syslog(LOG_NOTICE,
- "collect: unexpected close on connection from %s: %m\n",
- CurEnv->e_from.q_paddr, RealHostName);
- # endif
- (feof(InChannel) ? usrerr: syserr)
- ("collect: unexpected close, from=%s", CurEnv->e_from.q_paddr);
-
- /* don't return an error indication */
- CurEnv->e_to = NULL;
- CurEnv->e_flags &= ~EF_FATALERRS;
-
- /* and don't try to deliver the partial message either */
- finis();
- }
-
- /*
- ** Find out some information from the headers.
- ** Examples are who is the from person & the date.
- */
-
- eatheader(CurEnv);
-
- /*
- ** Add an Apparently-To: line if we have no recipient lines.
- */
-
- if (hvalue("to") == NULL && hvalue("cc") == NULL &&
- hvalue("bcc") == NULL && hvalue("apparently-to") == NULL)
- {
- register ADDRESS *q;
-
- /* create an Apparently-To: field */
- /* that or reject the message.... */
- for (q = CurEnv->e_sendqueue; q != NULL; q = q->q_next)
- {
- if (q->q_alias != NULL)
- continue;
- if (tTd(30, 3))
- printf("Adding Apparently-To: %s\n", q->q_paddr);
- addheader("apparently-to", q->q_paddr, CurEnv);
- }
- }
-
- if ((CurEnv->e_dfp = fopen(CurEnv->e_df, "r")) == NULL)
- syserr("Cannot reopen %s", CurEnv->e_df);
- }
- /*
- ** FLUSHEOL -- if not at EOL, throw away rest of input line.
- **
- ** Parameters:
- ** buf -- last line read in (checked for '\n'),
- ** fp -- file to be read from.
- **
- ** Returns:
- ** FALSE on error from sfgets(), TRUE otherwise.
- **
- ** Side Effects:
- ** none.
- */
-
- bool
- flusheol(buf, fp)
- char *buf;
- FILE *fp;
- {
- char junkbuf[MAXLINE], *sfgets();
- register char *p = buf;
-
- while (index(p, '\n') == NULL) {
- if (sfgets(junkbuf,MAXLINE,fp) == NULL)
- return(FALSE);
- p = junkbuf;
- }
-
- return(TRUE);
- }
- /*
- ** TFERROR -- signal error on writing the temporary file.
- **
- ** Parameters:
- ** tf -- the file pointer for the temporary file.
- **
- ** Returns:
- ** none.
- **
- ** Side Effects:
- ** Gives an error message.
- ** Arranges for following output to go elsewhere.
- */
-
- tferror(tf)
- FILE *tf;
- {
- if (errno == ENOSPC)
- {
- (void) freopen(CurEnv->e_df, "w", tf);
- fputs("\nMAIL DELETED BECAUSE OF LACK OF DISK SPACE\n\n", tf);
- usrerr("452 Out of disk space for temp file");
- }
- else
- syserr("collect: Cannot write %s", CurEnv->e_df);
- (void) freopen("/dev/null", "w", tf);
- }
- /*
- ** EATFROM -- chew up a UNIX style from line and process
- **
- ** This does indeed make some assumptions about the format
- ** of UNIX messages.
- **
- ** Parameters:
- ** fm -- the from line.
- **
- ** Returns:
- ** none.
- **
- ** Side Effects:
- ** extracts what information it can from the header,
- ** such as the date.
- */
-
- # ifndef NOTUNIX
-
- char *DowList[] =
- {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL
- };
-
- char *MonthList[] =
- {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
- NULL
- };
-
- eatfrom(fm)
- char *fm;
- {
- register char *p;
- register char **dt;
-
- if (tTd(30, 2))
- printf("eatfrom(%s)\n", fm);
-
- /* find the date part */
- p = fm;
- while (*p != '\0')
- {
- /* skip a word */
- while (*p != '\0' && *p != ' ')
- p++;
- while (*p == ' ')
- p++;
- if (!isupper(*p) || p[3] != ' ' || p[13] != ':' || p[16] != ':')
- continue;
-
- /* we have a possible date */
- for (dt = DowList; *dt != NULL; dt++)
- if (strncmp(*dt, p, 3) == 0)
- break;
- if (*dt == NULL)
- continue;
-
- for (dt = MonthList; *dt != NULL; dt++)
- if (strncmp(*dt, &p[4], 3) == 0)
- break;
- if (*dt != NULL)
- break;
- }
-
- if (*p != NULL)
- {
- char *q;
- extern char *arpadate();
-
- /* we have found a date */
- q = xalloc(25);
- (void) strncpy(q, p, 25);
- q[24] = '\0';
- define('d', q, CurEnv);
- q = arpadate(q);
- define('a', newstr(q), CurEnv);
- }
- }
-
- # endif NOTUNIX
- @
-
-
- 5.9.0.1
- log
- @IDA patches
- @
- text
- @d94 1
- a94 1
- # endif /* NOTUNIX */
- d238 1
- a238 1
- # endif /* LOG */
- d419 1
- a419 1
- # endif /* NOTUNIX */
- @
-
-
- 5.9.0.2
- log
- @Add (char) cast to NULL comparison.
- @
- text
- @d404 1
- a404 1
- if (*p != (char) NULL)
- @
-
-
- 5.9.0.3
- log
- @Added fsync() calls before close of df and cf files. Helps prevent lost
- mail on a system that's crashing often. Depending on performance lossage
- and portability constraints, this may need #ifdef PARANOID later.
- @
- text
- @a226 1
- (void) fsync(fileno(tf));
- @
-
-
- 5.9.0.4
- log
- @Added static keyword to declarations for tferror(), flusheol(), eatfrom().
- @
- text
- @d55 1
- a55 3
- extern bool isheader();
- static bool flusheol();
- static tferror(), eatfrom();;
- d296 1
- a296 1
- static bool
- a325 1
- static
- a369 1
- static
- @
-
-
- 5.9.0.5
- log
- @ANSIfied.
- @
- text
- @d25 2
- a26 2
- #include <errno.h>
- #include "sendmail.h"
- a27 10
- #ifdef __STDC__
- static bool flusheol(const char *, FILE *);
- static void tferror(FILE *);
- static void eatfrom(const char *);
- #else /* !__STDC__ */
- static bool flusheol();
- static void tferror();
- static void eatfrom();
- #endif /* __STDC__ */
-
- a46 1
- void
- d54 4
- d235 1
- d300 1
- a300 1
- const char *buf;
- d303 2
- a304 2
- char junkbuf[MAXLINE];
- register const char *p = buf;
- d328 1
- a328 1
- static void
- d373 1
- a373 1
- static void
- d375 1
- a375 1
- const char *fm;
- d377 1
- a377 1
- register const char *p = fm;
- d384 1
- d412 1
- @
-
-
- 5.9.0.6
- log
- @Put overly long headers (> 500 bytes) at end of message body. Adapted
- from Paul Vixie's patch.
- @
- text
- @d236 2
- a237 5
-
- /*
- * Since overly long headers are appended to the end of the message
- * body, delay closing tf until eatheader is done.
- */
- a249 1
- (void) fclose(tf);
- d264 1
- a264 5
- eatheader(CurEnv, tf);
-
- /* Now close the tf file */
- (void) fsync(fileno(tf));
- (void) fclose(tf);
- @
-
-
- 5.9.0.7
- log
- @Too many broken compilers out there that can't handle functions in
- conditional statements.
- @
- text
- @d251 2
- a252 12
- /*
- * So many broken compilers out there...
- * (feof(InChannel) ? usrerr: syserr)
- * ("collect: unexpected close, from=%s",
- * CurEnv->e_from.q_paddr);
- */
- if (feof(InChannel))
- usrerr("collect: unexpected close, from=%s",
- CurEnv->e_from.q_paddr);
- else
- syserr("collect: unexpected close, from=%s",
- CurEnv->e_from.q_paddr);
- @
-
-
- 5.9.0.8
- log
- @Character set translation changes adapted from patches from Keld Simonsen
- (keld@@dkuug.dk).
- @
- text
- @a64 5
- #ifdef BIT8
- char buf1[MAXFIELD+2];
- CHARSET *ch;
- char *chname, *chesc;
- #endif /* BIT8 */
- a206 11
- # ifdef BIT8
- chname = hvalue("x-charset");
- chesc = hvalue("x-char-esc");
- if (!chesc)
- chesc = "29";
- if (chname)
- ch = getchset(chname, atoi(chesc));
- else
- ch = CurEnv->e_from.q_mailer->m_charset;
- # endif /* BIT8 */
-
- a210 8
- # ifdef BIT8
- if (ch)
- {
- strncnv(ch, ascii, (CHAR8U *)buf1, (CHAR8U *)buf, sizeof buf1);
- strncpy(buf, buf1, sizeof buf);
- }
- # endif /* BIT8 */
-
- d330 1
- a330 2
- while (index(p, '\n') == NULL)
- {
- d332 1
- a332 1
- return (FALSE);
- d336 1
- a336 1
- return (TRUE);
- @
-
-
- 5.9.0.9
- log
- @Added RCS ID string
- @
- text
- @a22 1
- static char rcsid[] = "@@(#)$Id$";
- @
-
-
- 5.9.0.10
- log
- @Had first two arguments to strncnv() reversed.
- @
- text
- @d23 1
- a23 1
- static char rcsid[] = "@@(#)$Id: collect.c,v 5.9.0.9 1991/04/05 14:55:15 paul Exp paul $";
- d231 1
- a231 1
- strncnv(ascii, ch, (CHAR8U *)buf1, (CHAR8U *)buf, sizeof buf1);
- @
-
-
- 5.9.0.11
- log
- @fsync() now done only if SuperSafe is set.
- @
- text
- @d22 2
- a23 2
- static char sccsid[] = "@@(#)collect.c 5.9 (Berkeley) 6/1/90 %I% local";
- static char rcsid[] = "@@(#)$Id: collect.c,v 5.9.0.10 1991/04/30 16:44:59 paul Exp paul $";
- d99 1
- a99 1
- #ifndef NOTUNIX
- d109 1
- a109 1
- #endif /* NOTUNIX */
- d213 1
- a213 1
- #ifdef BIT8
- d222 1
- a222 11
- #endif /* BIT8 */
- #ifdef SYSV
- if (SuperSafe)
- {
- int fd = fileno(tf);
- int flags;
-
- if ((flags = fcntl(fd, F_GETFL)) != -1)
- (void) fcntl(fd, F_SETFL, flags | O_SYNC);
- }
- #endif /* SYSV */
- d228 1
- a228 1
- #ifdef BIT8
- d234 1
- a234 1
- #endif /* BIT8 */
- d270 1
- a270 1
- #ifdef LOG
- d275 1
- a275 1
- #endif /* LOG */
- d306 1
- a306 4
- #ifndef SYSV
- if (SuperSafe)
- (void) fsync(fileno(tf));
- #endif /* !SYSV */
- d409 1
- a409 1
- #ifndef NOTUNIX
- d472 1
- a472 1
- #endif /* NOTUNIX */
- @
-
-
- 5.9.0.12
- log
- @Simplified collection of header and body, eliminated goto readerr. Part of
- the System 5 and general improvement patches contributed by Bruce Lilly
- (bruce@@broadcast.sony.com).
- @
- text
- @d23 1
- a23 1
- static char rcsid[] = "@@(#)$Id: collect.c,v 5.9.0.11 1991/05/20 22:31:10 paul Exp paul $";
- d30 1
- d34 1
- d63 3
- a65 2
- char buf[MAXFIELD+2];
- register char *p;
- d96 2
- a97 6
- /*
- * Read errors here are caught inside the do loop. sfgets() will
- * set buf[0] to NULL and fixcrlf() will return immediately because
- * of that.
- */
- (void) sfgets(buf, sizeof buf, InChannel);
- d102 2
- d105 2
- a106 1
- (void) sfgets(buf, sizeof buf, InChannel);
- a115 1
- ** (See above)
- d118 8
- a125 5
- do {
- int c;
-
- /* drop out on error */
- if (ferror(InChannel))
- d127 1
- d130 5
- a134 6
- if (index(buf, '\n') == NULL)
- {
- while ((c = getc(InChannel)) != '\n' && c != EOF)
- continue;
- }
- fixcrlf(buf, TRUE);
- d136 1
- a136 3
- /* see if the header is over */
- if (!isheader(buf))
- break;
- d139 1
- a139 1
- while ((c = getc(InChannel)) == ' ' || c == '\t')
- d141 5
- a145 4
- p = &buf[strlen(buf)];
- *p++ = '\n';
- *p++ = c;
- if (sfgets(p, sizeof(buf) - (p - buf), InChannel) == NULL)
- d147 20
- a166 1
- fixcrlf(p, TRUE);
- a167 2
- if (!feof(InChannel) && !ferror(InChannel))
- (void) ungetc(c, InChannel);
- d169 19
- a187 1
- CurEnv->e_msgsize += strlen(buf);
- d193 1
- a193 1
- if (bitset(H_EOH, chompheader(buf, FALSE)))
- d195 1
- a195 1
- } while (sfgets(buf, sizeof(buf) - 2, InChannel) != NULL);
- d200 8
- a207 3
- /* throw away a blank line */
- if (buf[0] == '\0' && !ferror(InChannel))
- (void) sfgets(buf, sizeof(buf), InChannel);
- a237 3
- /* drop out on error */
- if (ferror(InChannel))
- break;
- d266 1
- a266 1
- } while (sfgets(buf, sizeof(buf), InChannel) != NULL);
- d268 1
- d283 1
- a283 1
- "collect: unexpected close on connection from %s: %m",
- d345 31
- @
-
-
- 5.9.0.13
- log
- @Removed #ifndef NOTUNIX around Dow strings (needed in arpatounix())
- @
- text
- @d23 1
- a23 1
- static char rcsid[] = "@@(#)$Id: collect.c,v 5.9.0.12 1991/05/21 17:27:50 paul Exp paul $";
- d350 2
- a362 2
-
- #ifndef NOTUNIX
- @
-
-
- 5.9.0.14
- log
- @Deleted extraneous parameter from syslog() call.
- @
- text
- @d22 2
- a23 2
- static char sccsid[] = "@@(#)collect.c 5.9 (Berkeley) 6/1/90";
- static char rcsid[] = "@@(#)$Id: collect.c,v 5.9.0.13 1991/05/29 19:36:13 paul Exp paul $";
- d243 1
- a243 1
- RealHostName);
- @
-